#include <func.h>

int main(int argc,char *argv[])
{
    if(fork()==0)
    {
        while(1);
        return 0;
    }
    else
    {
        int wstatus;
        while(1)
        {
            int ret=waitpid(-1,&wstatus,WNOHANG);
            if(ret!=0)
            {
                if(WIFEXITED(wstatus))
                {
                    printf("exit normally exit code= %d\n",WEXITSTATUS(wstatus));
                }
                else if(WIFSIGNALED(wstatus))
                {
                    printf("exit abnormally terminate signal=%d\n",WTERMSIG(wstatus));
                }
                break;
            }
            else
            {
                printf("the child process is still running\n");
                sleep(2);
            }


        }

    }

    return 0;
}

